#!/bin/bash
set -e

python_version=${1:-3.9.19}
docker_registry=${2-""}

script_dir="$(realpath $(dirname $0))"
source "$script_dir/util-lib.sh"
skip_if_no_changed_file_match "^(backend|concourse)"

source "$HOME/.bashrc"
pyenv shell "$python_version"

"$script_dir/install_docker"
source "$script_dir/docker-lib.sh"
start_docker "" "$docker_registry"

"$script_dir/install_backend_packages"
"$script_dir/create_backend_dirs" backend/test_storage_dir
cd backend
pip install -r requirements.txt -r requirements-test.txt
python setup.py develop
docker compose up -d redis
pytest --ignore "tracim_backend/tests/functional" --ignore "tracim_backend/tests/commands"
